-- PauseMenu
-- 暂停菜单
PauseMenu = class()

function PauseMenu:init()
    self.resumeButton = TextButton(250,HEIGHT / 2 + 100,LP.ResumeGame)
    self.resumeButton.font = "Futura-Medium"
    self.resumeButton.fontSize = 35
    self.resumeButton.clicked = function() GameState = Gaming guiRenderer.visible = true timer:resume() end
    self.resumeButton.backColor = color(255,255,255,0)
    self.resumeButton.textColor = color(255,255,255,255)
    
    self.restartButton = TextButton(250,HEIGHT / 2,LP.BackToMenu..LP.AndSave)
    self.restartButton.font = "Futura-Medium"
    self.restartButton.fontSize = 35
    self.restartButton.clicked = function() 
        game:saveGame()
        game = Game()
        collectgarbage()
        GameState = Start
    end
    self.restartButton.backColor = color(255,255,255,0)
    self.restartButton.textColor = color(255,255,255,255)
    
    self.consoleButton = TextButton(250,HEIGHT / 2 - 100,LP.OpenConsole)
    self.consoleButton.font = "Futura-Medium"
    self.consoleButton.fontSize = 35
    self.consoleButton.clicked = function() showConsole = true end
    self.consoleButton.backColor = color(255,255,255,0)
    self.consoleButton.textColor = color(255,255,255,255)
    self.consoleButton.visible = (TCMode ~= NoneMode)
end

function PauseMenu:draw()
    rectMode(CORNER)
    noStroke()
    fill(0, 0, 0, 120)
    rect(0,0,WIDTH,HEIGHT)
    fill(255, 255, 255, 100)
    rect(0,HEIGHT - 70,WIDTH,HEIGHT)
    fill(255, 255, 255, 255)
    font("Futura-Medium")
    fontSize(40)
    textMode(CENTER)
    text(LP.PauseGame,WIDTH / 2,HEIGHT - 35)
    self.resumeButton:draw()
    self.restartButton:draw()
    self.consoleButton:draw()
end

function PauseMenu:touched(touch)
    self.resumeButton:touched(touch)
    self.restartButton:touched(touch)
    self.consoleButton:touched(touch)
end
